fn main() {
    let mut stack = Vec::new();
    stack.push(1);
    stack.push(2);
    stack.push(3);
    //stack.pop从数组尾部弹出元素
    while let Some(top) = stack.pop() {
        println!("Pop: {top}");
    }

    //if-let 
    if let Some(x) = Some(5){println!("{}",x)};
    //let-esle
    let Some(x) = Some(6) else {return;};
    println!("{}", x);

    //当while let遇到嵌套Options时
    let my_arr = [Some(1), Some(2), Some(3), Some(4), None, Some(5)];
    let mut my_vec = Vec::from(my_arr);
    //while let Some(top) = my_vec.pop().unwrap() { //加上unwrap()解构嵌套Options
    //    println!("my_vec pop: {top:?} ");
    //}
    //另一种方法
   // while let Some(top) = my_vec.pop() {
   //     let Some(_) = top else {break;};

   // }
   //再另一种方法
    //while let Some(Some(top)) = my_vec.pop(){
    //    println!("my_vec pop:{top:?}");
    //}
    //再再另一种方法
    //while let Some(top) = my_vec.pop(){
    //    match top {
    //        Some(tp) => println!("my_vec pop:{tp:?}"),
    //        None => break,
    //    }
    //}
    //再再再另一种方法
    while let Some(top) = my_vec.pop(){
        if let Some(tp) = top {
            println!("my_vec pop:{}", tp);
        } else {
            break;
        }
    }
    println!("Curr my_vec value: {my_vec:?}");

    match 2 {
        num @ (1 | 2) => {
            println!("{}", num);
        }
        _ => {}
    }
}
